package dome4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-05-09
 * Time: 19:04
 */
//浅拷贝

class Student implements Cloneable {
    public String name;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test1 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Student student1 = new Student();
        student1.name = "Ydl";
        //只是克隆了student1所指的对象
        Student student2 = (Student) student1.clone();//向下转型(强转)
        System.out.println(student1);
        System.out.println(student2);
    }


}
